<template>
  <view class="content">
    <!-- 自定义导航栏 -->
    <tm-navbar color="blue" title="" hideHome :leftWidth="100">
      <template #left>
        <text class="nav-left">应用</text>
      </template>
      <template #right>
        <view class="nav-right" :style="{ paddingRight: rightPadding + 20 + 'rpx' }">
          <tm-icon
            :font-size="40"
            color="white"
            name="tmicon-scan"
            @click="scanCodeClick"
          ></tm-icon>
        </view>
      </template>
    </tm-navbar>
    <view class="body">
      <view class="body-grid">
        <custom-grid-view isShowRight @rightBtnClick="rightBtnClick"></custom-grid-view>
      </view>

      <view class="body-grid">
        <custom-grid-view></custom-grid-view>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
import { torpx } from "../../../tmui/tool/function/util";
import { at_scanCode } from "@/utils/util";
let rightPadding = 0;
// #ifdef MP-WEIXIN
rightPadding = 750 - torpx(uni.getMenuButtonBoundingClientRect().left);
// #endif

// 二维码扫一扫的点击事件
function scanCodeClick() {
  at_scanCode().then((res: UniApp.ScanCodeSuccessRes) => {
    console.log("扫码的结果是---", res);
  });
}

//gridview头部标题的右边的全部按钮的点击事件
function rightBtnClick() {
  uni.navigateTo({
    url: "/pages_application/all-application/all-application"
  });
}
</script>

<style lang="scss" scoped>
.content {
  height: 100vh;
}
.nav-left {
  color: white;
  font-size: 34rpx;
  font-weight: bold;
  padding-left: 20rpx;
}
.nav-right {
  color: white;
}
.body {
  height: calc(100% - 44px - var(--status-bar-height));
  background-color: pink;
  .body-grid {
    margin-bottom: 20rpx;
    background-color: white;
  }
}
</style>
